﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Module

    /// <summary>
    /// Module object for NHibernate mapped table 'Module'.
    /// </summary>
    [Serializable]
    public class Module : Persistent
    {
        #region Member Variables

        protected string _name;
        protected IList<Resource> _resources;
        protected int _parentID { get; set; }
        #endregion

        #region Constructors

        public Module() { }

        public Module(string name, DateTime createDate, DateTime modifyDate, int editUser)
        {
            this._name = name;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
        }

        #endregion

        #region Public Properties

        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual IList<Resource> Resources
        {
            get
            {
                if (_resources == null)
                {
                    _resources = new List<Resource>();
                }
                return _resources;
            }
            set { _resources = value; }
        }

        public virtual int ParentID
        {
            get { return _parentID; }
            set
            {
                _parentID = value;
            }
        }
        #endregion
    }
    #endregion
}